//
//  AppDelegate.m
//  YiXiu
//
//  Created by ZHY on 16/6/26.
//  Copyright © 2016年 zzz. All rights reserved.
//

#import "AppDelegate.h"
#import "LeftSortsViewController.h"
#import "LeftSlideViewController.h"
#import "BaseTabBarController.h"
#import "UMSocial.h"
#import "UMSocialQQHandler.h"
#import "UMSocialSinaSSOHandler.h"
#import "UMSocialWechatHandler.h"
#import "UMSocial.h"

#import "AlwayScrollerView.h"

#define sinaAppKey @"3858667553"
#define AppSecret @"04f9b30b5dc52bc7811b4e9bf469c267"
#define UmengAppkey @"578f224567e58e59c7001a65"


@interface AppDelegate ()

@end

@implementation AppDelegate


- (void)firsterBegin{
    


    UIImageView * imageV = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    imageV.image = [UIImage imageNamed:@"03"];
    imageV.userInteractionEnabled = YES;
    UITapGestureRecognizer * tap =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
    [imageV addGestureRecognizer:tap];
    tap.numberOfTapsRequired = 2;
    
    UIViewController * vc = [[UIViewController alloc] init];
    
    [vc.view addSubview:imageV];
    self.window.rootViewController = vc;
    
    
    
}
- (void)tapAction{
    BaseTabBarController *mainVC = [[BaseTabBarController alloc] init];
    
    self.mainNavigationController = mainVC;
    
    LeftSortsViewController *leftVC = [[LeftSortsViewController alloc] init];
    
    self.LeftSlideVC = [[LeftSlideViewController alloc] initWithLeftView:leftVC andMainView:self.mainNavigationController];
    self.window.rootViewController = self.LeftSlideVC;
    
    
    [[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0xfee77a)];
    
    //初始化友盟的Appkey
    [UMSocialData setAppKey:UmengAppkey];
    
    
    //初始化第三方登录授权
    [self setUpLogin];
}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];   //设置通用背景颜色
    [self.window makeKeyAndVisible];
    
    BaseTabBarController *mainVC = [[BaseTabBarController alloc] init];
    
    self.mainNavigationController = mainVC;
    
    LeftSortsViewController *leftVC = [[LeftSortsViewController alloc] init];
    
    self.LeftSlideVC = [[LeftSlideViewController alloc] initWithLeftView:leftVC andMainView:self.mainNavigationController];
    self.window.rootViewController = self.LeftSlideVC;
    
    
    [[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0xfee77a)];
    
    //初始化友盟的Appkey
    [UMSocialData setAppKey:UmengAppkey];
    
    
    //初始化第三方登录授权
    [self setUpLogin];
 
   
    
    return YES;
}
-(void)gotoMain{
}

-(void)makeLaunchView{
    
}

- (void)setUpLogin{
    
     //设置QQ微博授权登录
     [UMSocialQQHandler setQQWithAppId:@"1105483757" appKey:@"1LDmbMYIYmaVaBJz" url:@"http://www.umeng.com/social"];
    
    
    [UMSocialSinaSSOHandler openNewSinaSSOWithAppKey:sinaAppKey secret:AppSecret RedirectURL:@"http://sns.whalecloud.com/sina2/callback"];
    
    //微信
//    [UMSocialWechatHandler setWXAppId:<#(NSString *)#> appSecret:<#(NSString *)#> url:<#(NSString *)#>];
    
}


- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    BOOL result = [UMSocialSnsService handleOpenURL:url];
    if (result == FALSE) {
        //调用其他SDK，例如支付宝SDK等
    }
    return result;
}



- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
